package com.cc.controller;


import com.cc.service.GoodsService;
import com.dy.cc.Goods;
import com.kaoshi.common.config.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;


    @RequestMapping("findAll")
    public Result findAll(@RequestBody Goods goods) {
        List<Goods> goodsList = goodsService.findAll(goods);
        return Result.ok(goodsList);
    }

    @RequestMapping("xiao")
    public Result xiao(Integer uid) {
        List<Goods> list = goodsService.xiao(uid);
        return Result.ok(list);
    }

    @RequestMapping("shang")
    public Result shang(Integer uid) {
        List<Goods> list = goodsService.shang(uid);
        return Result.ok(list);
    }

    @RequestMapping("find")
    public Result find(Integer uid) {
        List<Goods> list = goodsService.find(uid);
        return Result.ok(list);
    }


    @RequestMapping("price")
    public Result price(Goods goods, Integer a, Integer uid) {
        List<Goods> list = goodsService.price(goods, a, uid);
        return Result.ok(list);
    }

    @RequestMapping("sousuo")
    public Result sousuo(@RequestBody Goods goods) {
        List<Goods> goodsList = goodsService.sousuo(goods);
        return Result.ok(goodsList);
    }

    @RequestMapping("All")
    public Result All(Goods goods, Integer uid) {
        List<Goods> goodsList = goodsService.All(goods, uid);
        return Result.ok(goodsList);
    }

    @RequestMapping("findList")
    public Result findList(@RequestBody Goods goods){
        List<Goods> goodsList = goodsService.findList(goods);
        return Result.ok(goodsList);
    }
    @RequestMapping("fAll")
    public Result fAll(Goods goods) {
        List<Goods> goodsList = goodsService.fAll(goods);
        return Result.ok(goodsList);
    }

    @RequestMapping("xiaoAll")
    public Result xiaoAll(Goods goods) {
        List<Goods> goodsList = goodsService.xiaoAll(goods);
        return Result.ok(goodsList);
    }

    @RequestMapping("shangAll")
    public Result shangAll(Goods goods) {
        List<Goods> goodsList = goodsService.shangAll(goods);
        return Result.ok(goodsList);
    }

    @RequestMapping("priceAll")
    public Result priceAll(Goods goods, Integer a) {
        List<Goods> list = goodsService.priceAll(goods, a);
        return Result.ok(list);
    }

    @GetMapping("cctj")
    public Result cctj(Integer uid){
//        goodsService.cctj();
        return Result.ok();
    }

}
